{include file="head_2" title="权限列表" /}
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body" style="padding: 15px;">
                    <div class="page_menu"><a href="/admin/rules/add.html" ><button class="layui-btn layui-btn-primary">添加</button></a></div>
                    <div style="clear:both"></div>
                    <table class="layui-table" lay-data="{ url:'/admin/rules/get_josn/', page:false, id:'idTest'}" lay-filter="demo">
                        <thead>
                            <tr>
                                <th lay-data="{field:'id', align:'center', width:80}">编号</th>
                                <th lay-data="{field:'name',align:'center', width:150}">名称</th>
                                <th lay-data="{field:'menulist', width:700}">链接</th>
                                <th lay-data="{field:'sort',  align:'center', width:100}">排序</th>
                                <th lay-data="{fixed: 'right', width:150, align:'center',toolbar: '#barDemo'}">操作</th>
                            </tr>
                        </thead>
                    </table>

                </div>
            </div>
        </div>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
</script>

<script>
    layui.use(['layer', 'table', 'jquery'], function () {
    var layer = layui.layer //弹层
            , table = layui.table //表格
            , $ = layui.$;

    //监听工具条
    table.on('tool(demo)', function (obj) {
        var data = obj.data
                , layEvent = obj.event;
        if (layEvent === 'del') {
            layer.confirm('真的删除行么', function (index) {
                del_data(obj);
                layer.close(index);
                //向服务端发送删除指令
            });
        } else if (layEvent === 'edit') {
            location.href = "/admin/rules/edit/id/" + data.id;
        }
    });
    function del_data(obj)
    {
        var data = obj.data;
        $.ajax({
            url: "/admin/rules/del_submit/",
            type: 'post',
            data: {id: data.id},
            dataType: 'json',
            success: function (data) {
                if (data.status == 1)
                {
                    layer.msg("删除成功!", {
                        time: 2000
                    }, function () {
                        location.reload();
                    });
                } else
                {
                    layer.msg(data.msg);
                }
            },
        });
     }
  });
</script>
{include file="foot" /}